package struts.action;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.EventDispatchAction;
import org.springframework.beans.factory.annotation.Autowired;

import util.CookieUtil;
import bean.UserObject;

public class LogoutAction extends EventDispatchAction {
	@Autowired
	UserObject userObject;

	/**
	 * 登出处理
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward init(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		// Save uo Object into session
		request.getSession().invalidate();

		// generate an empty cookie, add it to session
		Cookie ticket = CookieUtil.GenerateEmptyCookie();
		
		response.addCookie(ticket);

		//本画面に戻る
		return mapping.findForward("sucess");
	}
}
